from time import sleep
import uiautomation
import pyautogui


class SOAP():
    his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
    his.SetFocus()
    SOAP = his.TabItemControl(AutomationId='TabItem_soap', ClassName='TabItem', foundIndex=1)  # soap
    # SOAP__主观资料
    zhusu = his.EditControl(AutomationId='zs_txt', ClassName='TextBox')  # 编写主述
    xianbingshi = his.EditControl(AutomationId='xbs_txt', ClassName='TextBox')  # 现病史
    jiwangshi = his.EditControl(AutomationId='jws_txt', ClassName='TextBox')  # 既往史
    guomingshi = his.EditControl(AutomationId='gms_txt', ClassName='TextBox')  # 过敏史
    jiazushi = his.EditControl(AutomationId='jzs_txt', ClassName='TextBox')  # 家族史
    hunyinshi = his.EditControl(AutomationId='hys_txt', ClassName='TextBox')  # 婚姻史
    # SOAP__客观资料
    tiwen = his.EditControl(AutomationId='tbTiwen', ClassName='TextBox')  # 体温
    shenggao = his.EditControl(AutomationId='tbShengao', ClassName='TextBox')  # 身高
    tizhong = his.EditControl(AutomationId='tz_dtb', ClassName='TextBox')  # 体重
    xuetang = his.EditControl(AutomationId='xt_dtb', ClassName='TextBox')  # 血糖
    huxi = his.EditControl(AutomationId='hx_itb', ClassName='TextBox')  # 呼吸
    xinlv = his.EditControl(AutomationId='xl_itb', ClassName='TextBox')  # 心率
    xueyas = his.EditControl(AutomationId='xy_s_itb', ClassName='TextBox')  # 血压s
    xueyae = his.EditControl(AutomationId='xy_e_itb', ClassName='TextBox')  # 血压e
    fuzhujiancha = his.EditControl(AutomationId='fzjc_txt', ClassName='TextBox')  # 辅助检查
    jianyi = his.EditControl(AutomationId='zljhjy_txt', ClassName='TextBox')  # 建议
    # SOAP__问题评估
    xiyizhenduan = his.TabControl(AutomationId='soapa', ClassName='TabControl').TabItemControl(Name='西医诊断',ClassName='TabItem')  # 西医诊断
    zhongyizhenduan = his.TabControl(AutomationId='soapa', ClassName='TabControl').TabItemControl(AutomationId='TCMDiagnosis', ClassName='TabItem')  # 中医诊断
    zhenduanjieguoshujukuang = his.DataGridControl(AutomationId='dgWenti', ClassName='YDataGrid').DataItemControl(Name='Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.SOAP.SOAP_A_Model_MB', ClassName='DataGridRow')  # 诊断结果
    zhenduanjieguo = his.ButtonControl(AutomationId='PART_ToggleButton', ClassName='Button')  # 诊断结果下拉按钮

    # 点击soap
    def click_SOAP_btn(self):
        self.SOAP.DoubleClick()
        sleep(1)

#SOAP————问题评估
        #点击西医诊断
    def click_xyzd_btn(self):
            self.xiyizhenduan.Click()
            sleep(1)
        #点击西医诊断
    def click_zyzd_btn(self):
            self.zhongyizhenduan.Click()
            sleep(1)

        #选择诊断结果
    def choose_zdjg_btn(self):
            self.zhenduanjieguoshujukuang.DoubleClick()
            sleep(0.5)
            self.zhenduanjieguoshujukuang.SendKeys("1型糖尿病伴血糖控制不佳")
            sleep(2)
            # self.zhenduanjieguo.Click()
            # sleep(0.5)
            # pyautogui.keyDown('down')
            pyautogui.press('enter')

#SOAP————主观资料
        #主诉
    def input_zs(self):
            self.zhusu.SendKeys('测试文本')
        #现病史
    def input_xbs(self):
            self.xianbingshi.SendKeys("测试文本")
        #既往史
    def input_jws(self):
            self.jiwangshi.SendKeys('测试文本')
        #过敏史
    def input_gms(self):
            self.guomingshi.SendKeys('测试文本')
        #家族史
    def input_jzs(self):
            self.jiazushi.SendKeys('测试文本')
        #主诉
    def input_hys(self):
            self.hunyinshi.SendKeys('测试文本')
        #输入主观资料
    def input_zgzl(self):
            self.zhusu.SendKeys('测试文本')
            self.xianbingshi.SendKeys("测试文本")
            self.jiwangshi.SendKeys('测试文本')
            self.guomingshi.SendKeys('测试文本')
            self.jiazushi.SendKeys('测试文本')
            self.hunyinshi.SendKeys('测试文本')
#SOAP————客观资料
        #体温
    def input_tw(self):
            self.tiwen.SendKeys('37')
        #shengao
    def input_sg(self):
            self.shenggao.SendKeys('180')
        #体重
    def input_tz(self):
            self.tizhong.SendKeys('80')
        #血糖
    def input_xt(self):
            self.xuetang.SendKeys('8')
        #呼吸
    def input_hx(self):
            self.huxi.SendKeys('40')
        #心率
    def input_xl(self):
            self.xinlv.SendKeys('140')
        #血压s
    def input_xys(self):
            self.xueyas.SendKeys('140')
        #血压e
    def input_xye(self):
            self.xueyae.SendKeys('80')
        #辅助检查
    def input_fzjc(self):
            self.fuzhujiancha.SendKeys('测试文本')
        #输入客观资料
    def input_kgzl(self):
            self.tiwen.SendKeys('37')
            self.shenggao.SendKeys('180')
            self.tizhong.SendKeys('80')
            self.xuetang.SendKeys('8')
            self.huxi.SendKeys('40')
            self.xinlv.SendKeys('140')
            self.xueyas.SendKeys('140')
            self.xueyae.SendKeys('80')
            self.fuzhujiancha.SendKeys('测试文本')
#SOAP__治疗计划
        #输入建议
    def input_jy(self):
            self.jianyi.SendKeys('测试文本')


